/**
 * 
 */
package cn.nawang.ebeim.api.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.nawang.ebeim.api.bean.IsOnLineBean;
import cn.nawang.ebeim.api.comm.BaseController;
import cn.nawang.ebeim.api.domain.HeartLog;
import cn.nawang.ebeim.api.service.HeartLogService;
import cn.nawang.ebeim.api.utils.Constant;

/**
 * @ClassName: HeartLogController
 * @Description: 心跳控制器
 * @author zhangjf
 * @date 2015年10月28日10:36:18
 * @version v1.0
 */
@RestController
public class HeartLogController extends BaseController {
  private static final Logger LOG = LoggerFactory.getLogger(HeartLogController.class);

  @Autowired
  private HeartLogService heartLogService;

  @RequestMapping(value = "/token/heartlog/save", method = RequestMethod.GET)
  public Object save(HeartLog heartLog) {
    LOG.debug("/token/heartlog/save {}", heartLog);
    Map<String, Object> map = new HashMap<String, Object>();
    heartLogService.save(heartLog);
    map.put(Constant.JSON_CODE, Constant.CODE_200);
    LOG.debug("save {}", map);
    return map;
  }

  @RequestMapping(value = "/token/isonline", method = RequestMethod.GET)
  public Object getIsOnLineBeans(String userId, String terminalId, String deviceName) {
    LOG.debug("/token/isonline {}", userId, terminalId, deviceName);
    Map<String, Object> map = new HashMap<String, Object>();
    // List<IsOnLineBean> list = heartLogService.getIsOnLineBeansList(userId);
    List<IsOnLineBean> list = heartLogService.getIsOnLineBeansList(userId, terminalId, deviceName);
    map.put(Constant.JSON_CODE, Constant.CODE_200);
    map.put("list", list);
    LOG.debug("getIsOnLineBeans {}", map);
    return map;
  }

}
